<template>
    <!--首页-->
    <div>
        <el-container>
            <!--头部-->
            <el-header style="font-size: 12px;position: relative">
                <!--左侧-->
                <div>
                    <div class="homeLogo">
                        <img src="../assets/logo.png" alt="" class="logoImg">
                    </div>
                    <div class="homesystemNameCtl">
                        <span class="homesystemName">ERP采购管理系统</span>
                    </div>
                </div>
                <!--中部-->
                <!--组件菜单-->
                <div class="topMenu" style="">
                    <el-menu default-active="/news" class="el-menu-demo" mode="horizontal"
                             background-color="#009DD9"
                             text-color="#fff"
                             :router=false
                    >
                        <el-menu-item index="/news">处理中心</el-menu-item>
                        <el-menu-item index="/dispatch">个人中心</el-menu-item>
                        <el-menu-item index="/dispatch">设置</el-menu-item>
                    </el-menu>
                </div>
                <!--路由自设定-->
                <!--右侧-->
                <div class="homeUser">
                    <span>admin</span>
                </div>
                <div class="homeUserUot" @click="logOut">
                    <el-button icon="el-icon-close" circle ></el-button>
                </div>
            </el-header>
            <el-container>
                <el-aside width="200px" style="background-color: rgb(238, 241, 246);max-height: 800px;overflow-y:auto;overflow-x:hidden  ">
                    <el-menu :default-openeds="['cght']"
                             :router=true
                             :default-active="LeftactiveIndex"
                             @select="handleSelectLeftMenu"
                    >
                        <el-submenu v-if="false" index="1">
                            <template slot="title"><i class="el-icon-s-data"></i>数据管理</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/dataManagement/skuMg">sku管理</el-menu-item>
                                <el-menu-item index="/dataManagement/cangkuMg">仓库管理</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <el-submenu v-if="false" index="2">
                            <template slot="title"><i class="el-icon-truck"></i>采购管理</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/ProcurementManagement/yaohuoMg">要货管理</el-menu-item>
                                <el-menu-item index="/ProcurementManagement/caigouMG">采购订单</el-menu-item>
                                <el-menu-item index="/ProcurementManagement/dianshouDanMg">点收单</el-menu-item>
                                <el-menu-item index="/ProcurementManagement/yanshouDanMg">验收单</el-menu-item>
                                <el-menu-item index="/ProcurementManagement/caigouTuiHuoDanMg">采购退货单</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <el-submenu v-if="false" index="3">
                            <template slot="title"><i class="el-icon-menu"></i>库存管理</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/kuCunManagement/initRuKuMg">初始入库</el-menu-item>
                                <el-menu-item index="/kuCunManagement/jieHuoDanMg">借货单</el-menu-item>
                                <el-menu-item index="/kuCunManagement/jieHuoFanHuanMg">借货返还</el-menu-item>
                            </el-menu-item-group>
                            <el-menu-item-group title="分组2">
                                <el-menu-item index="/kuCunManagement/kucunTiaoZhenMg">库存调整</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <!--采购合同-->
                        <el-submenu index="cght">
                            <template slot="title"><i class="el-icon-menu"></i>采购合同</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/kuCunManagement/initRuKuMg">采购合同-新增</el-menu-item>
                                <el-menu-item index="/kuCunManagement/initRuKuMg">采购合同-维护</el-menu-item>
                                <el-menu-item index="/kuCu">合同执行情况报表</el-menu-item>
                                <el-menu-item index="/kuCu">合同金额执行明细表</el-menu-item>
                                <el-menu-item index="/kuCu">合同金额执行汇总表</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <!--采购申请-->
                        <el-submenu index="cgsq">
                            <template slot="title"><i class="el-icon-menu"></i>采购申请</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/cgsqdMg/add">采购申请单-新增</el-menu-item>
                                <el-menu-item index="/cgsqdMg/weihu">采购申请单-维护</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <!--采购订单-->
                        <el-submenu index="cgdd">
                            <template slot="title"><i class="el-icon-menu"></i>采购订单</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/kuCunMa">采购订单-新增</el-menu-item>
                                <el-menu-item index="/kuCunMa">采购订单-维护</el-menu-item>
                                <el-menu-item index="/kuCunMa">采购订单-查看</el-menu-item>
                                <el-menu-item index="/kuCunMa">采购订单执行情况汇总表</el-menu-item>
                                <el-menu-item index="/kuCunMa">采购订单执行情况明细表</el-menu-item>
                                <el-menu-item index="/kuCunMa">采购订单全程跟踪报表</el-menu-item>

                            </el-menu-item-group>
                        </el-submenu>
                        <!--收料通知-->
                        <el-submenu index="sltz">
                            <template slot="title"><i class="el-icon-menu"></i>收料通知</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/kuCunMa">收料通知/请检单 - 新增</el-menu-item>
                                <el-menu-item index="/kuCunMa">收料通知/请检单 - 扫描录单</el-menu-item>
                                <el-menu-item index="/kuCunMa">收料通知/请检单 - 维护</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <!--外购入库-->
                        <el-submenu index="wgrk">
                            <template slot="title"><i class="el-icon-menu"></i>外购入库</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/kuC">外购入库-新增</el-menu-item>
                                <el-menu-item index="/kuC">外购入库-扫描录单</el-menu-item>
                                <el-menu-item index="/kuC">外购入库-维护</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <!--采购发票-->
                        <el-submenu index="cgfp">
                            <template slot="title"><i class="el-icon-menu"></i>采购发票</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/kuCunM">采购发票 - 新增</el-menu-item>
                                <el-menu-item index="/kuCunM">采购发票（专用） - 扫描录单</el-menu-item>
                                <el-menu-item index="/kuCunM">采购发票（普通） - 扫描录单</el-menu-item>
                                <el-menu-item index="/kuCunM">采购发票  - 维护</el-menu-item>
                                <el-menu-item index="/kuCunM">采购发票  - 钩稽日志</el-menu-item>
                                <el-menu-item index="/kuCunM">采购发票明细表</el-menu-item>
                                <el-menu-item index="/kuCunM">工序委外加工费对账表</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <!--费用发票-->
                        <el-submenu index="fyfp">
                            <template slot="title"><i class="el-icon-menu"></i>费用发票</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/kuCunM">费用发票 - 新增</el-menu-item>
                                <el-menu-item index="/kuCunM">费用发票 - 维护</el-menu-item>
                                <el-menu-item index="/kuCunM">费用发票汇总表</el-menu-item>
                                <el-menu-item index="/kuCunM">费用发票 - 新增</el-menu-item>
                                <el-menu-item index="/kuCunM">费用发票明细表</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <!--退料通知-->
                        <el-submenu index="tltz">
                            <template slot="title"><i class="el-icon-menu"></i>退料通知</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/kuCunManagement/initRuKuMg">退料通知 - 新增</el-menu-item>
                                <el-menu-item index="/kuCunManagement/initRuKuMg">退料通知 - 维护</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                        <!--库存查询-->
                        <el-submenu index="kccx">
                            <template slot="title"><i class="el-icon-menu"></i>库存查询</template>
                            <el-menu-item-group>
                                <template slot="title">分组一</template>
                                <el-menu-item index="/kuCunManagement/initRuKuMg">即时库存查询</el-menu-item>
                                <el-menu-item index="/kuCunManagement/initRuKuMg">库存状态查询</el-menu-item>
                            </el-menu-item-group>
                        </el-submenu>
                    </el-menu>
                </el-aside>
                <!--中部切换-->
                <el-main>
                    <router-view/>
                </el-main>

            </el-container>
        </el-container>
        <!--底部-->
        <el-footer style="width: 1080px"><span class="homeFooter">ERP采购管理系统   版本:1.0.1</span></el-footer>
    </div>
</template>

<script>
  import HelloWorld from '@/components/HelloWorld.vue';
  import newsApi from '@/api/news';
  import TEST from '@/api/test';

  export default {
    name: 'Home',
    components: {
      HelloWorld,
    },
    data() {
      return {
        LeftactiveIndex: '/ProcurementManagement/yaohuoMg',
      };
    },

    created() {
      // this.getData();
    },
    methods: {
      handleSelectLeftMenu(index) {
        this.LeftactiveIndex = index;
        this.$router.push('index');
      },
      logOut(){
        this.$router.push('/')
      },
      //获取数据，无条件则获取全部数据
      getData() {
        console.log('用户信息');
        newsApi.findByPage({}).then(res => {
          // 返回数据
          console.log(res);
        }).catch(err => {
          // 异常情况
        });

      },
      getTest() {
        TEST.querySubscriber({
          fleetId: 67,
          all: 1,
        }).then(res => {
          // 返回数据
          console.log(res);
        }).catch(err => {
          // 异常情况
        });

      },
      handleReset() {
        this.$refs.form.resetFields();
        this.$emit('on-reset');
      },
      /*新增*/
      handleOpenCreate() {
        this.createData.noticeTitle = '';
        this.createData.content = '';
        this.createData.createBy = '';
        this.createData.noticeType = '';
        this.updateIndex = -1;
        this.showCreate = true;
      },

      //编辑
      handleEdit(mesId) {
        this.editMesId = mesId;
        newsApi.getMessageInfoById({
          mesId,
        }).then(res => {
          // 返回数据
          this.createData = res;
        }).catch(err => {
          // 异常情况
        });
        this.updateIndex = 11;
        this.showCreate = true;
      },
      // 新增数据
      handleCreate() {
        this.$refs.create.validate((valid) => {
          if (valid) {
            if (this.updateIndex < 0) {
              // 新建
              newsApi.addMessage({
                noticeTitle: this.createData.noticeTitle,
                content: this.createData.content,
                createBy: this.createData.createBy,
                noticeType: this.createData.noticeType,
              }).then(res => {
                // 返回数据
                this.$Message.success('创建成功');
                this.getData();
              }).catch(err => {
                // 异常情况
              });

            } else {
              // 修改
              newsApi.updateMessage({
                mesId: this.editMesId,
                noticeTitle: this.createData.noticeTitle,
                content: this.createData.content,
                createBy: this.createData.createBy,
                noticeType: this.createData.noticeType,
              }).then(res => {
                // 返回数据
                this.$Message.success('修改成功');
                this.getData();
              }).catch(err => {
                // 异常情况
              });

            }

            this.showCreate = false;
            this.creating = false;
            this.$nextTick(() => {
              this.creating = true;
            });
          } else {
            this.creating = false;
            this.$nextTick(() => {
              this.creating = true;
            });
          }
        });
      },

      // 详情
      showDetail(dxmbTywysbm) {
        const item = dxmbTywysbm;
        this.$router.push({
          path: '/employee/comuser/comuser-detail',
          name: 'comuser-detail',
          params: {
            item,
          },
        });
      },

      //删除
      handleDelete(mesId) {
        this.$Modal.confirm({
          title: '删除',
          content: '确定删除吗？',
          onOk: () => {
            newsApi.deleteById({
              mesId,
            }).then(res => {
              // 返回数据
              this.$Message.success('删除成功');
              this.getData();
            }).catch(err => {
              // 异常情况
              this.$Message.error('删除失败');
            });
          },
        });
      },
    },
  };
</script>
<style scoped>
    a {
        text-decoration: none;
    }

    .router-link-active {
        text-decoration: none;
    }

    body {
        margin: 0;
        padding: 0;
    }

    .el-container {
        height: 100%;
        padding: 0;
        margin: 0;
        width: 100%;
    }

    .el-header {
        /*background-color: #282828;*/
        background-color: #B3C0D1;
        color: #fff;
        text-align: left;
        line-height: 60px;
        padding: 0;
        overflow: hidden;
    }


    .el-footer {
        background-color: #B3C0D1;
        color: #333;
        text-align: center;
        line-height: 60px;
    }

    .el-aside {
        background-color: #D3DCE6;
        color: #333;
        text-align: center;
        line-height: 200px;
    }

    .el-main {
        background-color: #E9EEF3;
        color: #333;
        /*text-align: center;*/
        /*line-height: 160px;*/
        padding: 0;
        margin: 0;
    }

    body > .el-container {
        margin-bottom: 20px;

    }

    .el-container:nth-child(5) .el-aside,
    .el-container:nth-child(6) .el-aside {
        line-height: 260px;
    }

    .el-container:nth-child(7) .el-aside {
        line-height: 320px;
    }

    /*头部*/
    .leftContent {
        margin: 0 !important;
        padding: 0;
        cursor: pointer;
    }

    .el-row {
        margin-bottom: 20px;
    }

    last-child {
        margin-bottom: 0;
    }

    .el-col {
        border-radius: 4px;
    }

    .bg-purple-dark {
        background: #009DD9;
    }

    .bg-bgc {
        margin-top: 2%;
        background: #009DD9;
    }

    .bg-purple {
        background: #d3dce6;
    }

    .bg-purple-light {
        background: #e5e9f2;
    }

    .grid-content {
        border-radius: 4px;
        min-height: 36px;
    }

    .row-bg {
        padding: 10px 0;
        background-color: #f9fafc;
    }

    /*头部结束*/

    /*中部开始*/
    .contentText {
        color: #fff;
        cursor: pointer;
    }

    /*中部结束*/

    /*右侧开始*/
    .rightpointer {
        cursor: pointer;
    }

    /*右侧头部结束*/


</style>
